{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.append(\"..\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from optimus import Optimus\n",
    "\n",
    "from pyspark.sql.session import SparkSession\n",
    "from pyspark.sql.types import StructType, StructField, StringType, BooleanType, IntegerType, ArrayType"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create optimus\n",
    "op = Optimus()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+-------------------+---+-------+-----+------+------+\n",
      "|              words|num|animals|thing|second|filter|\n",
      "+-------------------+---+-------+-----+------+------+\n",
      "|  I like     fish  |  1|dog dog|housé|     5|     a|\n",
      "|            zombies|  2|    cat|   tv|     6|     b|\n",
      "|simpsons   cat lady|  2|   frog|table|     7|     1|\n",
      "|               null|  3|  eagle|glass|     8|     c|\n",
      "+-------------------+---+-------+-----+------+------+\n",
      "\n"
     ]
    }
   ],
   "source": [
    "df = op.create.df([\n",
    "                (\"words\", \"str\", True),\n",
    "                (\"num\", \"int\", True),\n",
    "                (\"animals\", \"str\", True),\n",
    "                (\"thing\", StringType(), True),\n",
    "                (\"second\", \"int\", True),\n",
    "                (\"filter\", StringType(), True)\n",
    "            ],\n",
    "            [\n",
    "                (\"  I like     fish  \", 1, \"dog dog\", \"housé\", 5 , \"a\"),\n",
    "                (\"    zombies\", 2, \"cat\", \"tv\", 6, \"b\"),\n",
    "                (\"simpsons   cat lady\", 2, \"frog\", \"table\", 7, \"1\"),\n",
    "                (None, 3, \"eagle\", \"glass\", 8, \"c\")\n",
    "                \n",
    "            ])\n",
    "\n",
    "df.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('words', 'string'),\n",
       " ('num', 'int'),\n",
       " ('animals', 'string'),\n",
       " ('thing', 'string'),\n",
       " ('second', 'int'),\n",
       " ('filter', 'string')]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.dtypes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Append row\n",
    "### Spark\n",
    "Not available in Spark. You need to create a dataframe and the union to append a row"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       "    .data_type {\n",
       "        font-size: 0.8em;\n",
       "        font-weight: normal;\n",
       "    }\n",
       "\n",
       "    .column_name {\n",
       "        font-size: 1.2em;\n",
       "    }\n",
       "\n",
       "    .info_items {\n",
       "        margin: 10px 0;\n",
       "        font-size: 0.8em;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(even) {\n",
       "        background-color: #f2f2f2 !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(odd) {\n",
       "        background-color: #ffffff !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table thead {\n",
       "        border-bottom: 1px solid black;\n",
       "    }\n",
       "    .optimus_table{\n",
       "        font-size: 12px;\n",
       "    }\n",
       "\n",
       "</style>\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "<div class=\"info_items\">Viewing 5 of 5 rows / 6 columns</div>\n",
       "<div class=\"info_items\">8 partition(s)</div>\n",
       "\n",
       "<table class=\"optimus_table\">\n",
       "    <thead>\n",
       "    <tr>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">words</div>\n",
       "            <div class=\"data_type\">1 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">num</div>\n",
       "            <div class=\"data_type\">2 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">animals</div>\n",
       "            <div class=\"data_type\">3 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">thing</div>\n",
       "            <div class=\"data_type\">4 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">second</div>\n",
       "            <div class=\"data_type\">5 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">filter</div>\n",
       "            <div class=\"data_type\">6 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "    </tr>\n",
       "\n",
       "    </thead>\n",
       "    <tbody>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱I⸱like⸱⸱⸱⸱⸱fish⸱⸱\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            1\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            dog⸱dog\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            housé\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            5\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            a\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱⸱⸱zombies\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            2\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            cat\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            tv\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            6\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            b\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            simpsons⸱⸱⸱cat⸱lady\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            2\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            frog\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            table\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            7\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            1\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            None\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            3\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            eagle\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            glass\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            8\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            c\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            this⸱is⸱a⸱word\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            2\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            this⸱is⸱an⸱animal\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            this⸱is⸱a⸱thing\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            64\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            this⸱is⸱a⸱filter\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    </tbody>\n",
       "</table>\n",
       "\n",
       "<div class=\"info_items\">Viewing 5 of 5 rows / 6 columns</div>\n",
       "<div class=\"info_items\">8 partition(s)</div>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df.rows.append([\"this is a word\",2, \"this is an animal\", \"this is a thing\", 64, \"this is a filter\"]).table()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Append a dataframe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_bat = op.create.df(\n",
    "    [\n",
    "        (\"words\", \"str\", True),\n",
    "        (\"num\", \"int\", True),\n",
    "        (\"animals\", \"str\", True),\n",
    "        (\"thing\", StringType(), True),\n",
    "        (\"two strings\", StringType(), True),\n",
    "        (\"filter\", StringType(), True),\n",
    "        (\"num 2\", \"string\", True),\n",
    "        (\"col_array\", ArrayType(StringType()), True),\n",
    "        (\"col_int\", ArrayType(IntegerType()), True)\n",
    "\n",
    "    ],[\n",
    "        (\"I am batman\", 1, \"bat\", \"housé\", \"cat-car\", \"z\", \"10\", [\"screen\", \"sorry\"], [11, 21, 31]),\n",
    "\n",
    "    ])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.rows.append(df_bat).table()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Sort"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Sort columns desc (This is the default value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       "    .data_type {\n",
       "        font-size: 0.8em;\n",
       "        font-weight: normal;\n",
       "    }\n",
       "\n",
       "    .column_name {\n",
       "        font-size: 1.2em;\n",
       "    }\n",
       "\n",
       "    .info_items {\n",
       "        margin: 10px 0;\n",
       "        font-size: 0.8em;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(even) {\n",
       "        background-color: #f2f2f2 !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(odd) {\n",
       "        background-color: #ffffff !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table thead {\n",
       "        border-bottom: 1px solid black;\n",
       "    }\n",
       "    .optimus_table{\n",
       "        font-size: 12px;\n",
       "    }\n",
       "\n",
       "</style>\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "<div class=\"info_items\">Viewing 4 of 4 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n",
       "\n",
       "<table class=\"optimus_table\">\n",
       "    <thead>\n",
       "    <tr>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">words</div>\n",
       "            <div class=\"data_type\">1 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">num</div>\n",
       "            <div class=\"data_type\">2 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">animals</div>\n",
       "            <div class=\"data_type\">3 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">thing</div>\n",
       "            <div class=\"data_type\">4 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">second</div>\n",
       "            <div class=\"data_type\">5 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">filter</div>\n",
       "            <div class=\"data_type\">6 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "    </tr>\n",
       "\n",
       "    </thead>\n",
       "    <tbody>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            simpsons⸱⸱⸱cat⸱lady\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            2\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            frog\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            table\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            7\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            1\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            None\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            3\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            eagle\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            glass\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            8\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            c\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱I⸱like⸱⸱⸱⸱⸱fish⸱⸱\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            1\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            dog⸱dog\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            housé\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            5\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            a\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱⸱⸱zombies\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            2\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            cat\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            tv\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            6\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            b\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    </tbody>\n",
       "</table>\n",
       "\n",
       "<div class=\"info_items\">Viewing 4 of 4 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df.rows.sort(\"animals\").table()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       "    .data_type {\n",
       "        font-size: 0.8em;\n",
       "        font-weight: normal;\n",
       "    }\n",
       "\n",
       "    .column_name {\n",
       "        font-size: 1.2em;\n",
       "    }\n",
       "\n",
       "    .info_items {\n",
       "        margin: 10px 0;\n",
       "        font-size: 0.8em;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(even) {\n",
       "        background-color: #f2f2f2 !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(odd) {\n",
       "        background-color: #ffffff !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table thead {\n",
       "        border-bottom: 1px solid black;\n",
       "    }\n",
       "    .optimus_table{\n",
       "        font-size: 12px;\n",
       "    }\n",
       "\n",
       "</style>\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "<div class=\"info_items\">Viewing 4 of 4 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n",
       "\n",
       "<table class=\"optimus_table\">\n",
       "    <thead>\n",
       "    <tr>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">words</div>\n",
       "            <div class=\"data_type\">1 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">num</div>\n",
       "            <div class=\"data_type\">2 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">animals</div>\n",
       "            <div class=\"data_type\">3 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">thing</div>\n",
       "            <div class=\"data_type\">4 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">second</div>\n",
       "            <div class=\"data_type\">5 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">filter</div>\n",
       "            <div class=\"data_type\">6 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "    </tr>\n",
       "\n",
       "    </thead>\n",
       "    <tbody>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            simpsons⸱⸱⸱cat⸱lady\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            2\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            frog\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            table\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            7\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            1\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            None\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            3\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            eagle\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            glass\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            8\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            c\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱I⸱like⸱⸱⸱⸱⸱fish⸱⸱\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            1\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            dog⸱dog\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            housé\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            5\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            a\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱⸱⸱zombies\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            2\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            cat\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            tv\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            6\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            b\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    </tbody>\n",
       "</table>\n",
       "\n",
       "<div class=\"info_items\">Viewing 4 of 4 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df.rows.sort(\"animals\", \"desc\").table()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Sort by multiples columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       "    .data_type {\n",
       "        font-size: 0.8em;\n",
       "        font-weight: normal;\n",
       "    }\n",
       "\n",
       "    .column_name {\n",
       "        font-size: 1.2em;\n",
       "    }\n",
       "\n",
       "    .info_items {\n",
       "        margin: 10px 0;\n",
       "        font-size: 0.8em;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(even) {\n",
       "        background-color: #f2f2f2 !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(odd) {\n",
       "        background-color: #ffffff !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table thead {\n",
       "        border-bottom: 1px solid black;\n",
       "    }\n",
       "    .optimus_table{\n",
       "        font-size: 12px;\n",
       "    }\n",
       "\n",
       "</style>\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "<div class=\"info_items\">Viewing 4 of 4 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n",
       "\n",
       "<table class=\"optimus_table\">\n",
       "    <thead>\n",
       "    <tr>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">words</div>\n",
       "            <div class=\"data_type\">1 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">num</div>\n",
       "            <div class=\"data_type\">2 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">animals</div>\n",
       "            <div class=\"data_type\">3 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">thing</div>\n",
       "            <div class=\"data_type\">4 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">second</div>\n",
       "            <div class=\"data_type\">5 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">filter</div>\n",
       "            <div class=\"data_type\">6 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "    </tr>\n",
       "\n",
       "    </thead>\n",
       "    <tbody>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            simpsons⸱⸱⸱cat⸱lady\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            2\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            frog\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            table\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            7\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            1\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            None\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            3\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            eagle\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            glass\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            8\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            c\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱I⸱like⸱⸱⸱⸱⸱fish⸱⸱\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            1\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            dog⸱dog\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            housé\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            5\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            a\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱⸱⸱zombies\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            2\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            cat\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            tv\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            6\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            b\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    </tbody>\n",
       "</table>\n",
       "\n",
       "<div class=\"info_items\">Viewing 4 of 4 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df.rows.sort([(\"animals\",\"desc\"),(\"thing\",\"asc\")]).table()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "animals\n",
      "thing\n"
     ]
    }
   ],
   "source": [
    "a = [(\"animals\",\"desc\"),(\"thing\",\"asc\")]\n",
    "for c in a:\n",
    "    print(c[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Select"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       "    .data_type {\n",
       "        font-size: 0.8em;\n",
       "        font-weight: normal;\n",
       "    }\n",
       "\n",
       "    .column_name {\n",
       "        font-size: 1.2em;\n",
       "    }\n",
       "\n",
       "    .info_items {\n",
       "        margin: 10px 0;\n",
       "        font-size: 0.8em;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(even) {\n",
       "        background-color: #f2f2f2 !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(odd) {\n",
       "        background-color: #ffffff !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table thead {\n",
       "        border-bottom: 1px solid black;\n",
       "    }\n",
       "    .optimus_table{\n",
       "        font-size: 12px;\n",
       "    }\n",
       "\n",
       "</style>\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "<div class=\"info_items\">Viewing 1 of 1 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n",
       "\n",
       "<table class=\"optimus_table\">\n",
       "    <thead>\n",
       "    <tr>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">words</div>\n",
       "            <div class=\"data_type\">1 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">num</div>\n",
       "            <div class=\"data_type\">2 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">animals</div>\n",
       "            <div class=\"data_type\">3 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">thing</div>\n",
       "            <div class=\"data_type\">4 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">second</div>\n",
       "            <div class=\"data_type\">5 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">filter</div>\n",
       "            <div class=\"data_type\">6 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "    </tr>\n",
       "\n",
       "    </thead>\n",
       "    <tbody>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱I⸱like⸱⸱⸱⸱⸱fish⸱⸱\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            1\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            dog⸱dog\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            housé\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            5\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            a\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    </tbody>\n",
       "</table>\n",
       "\n",
       "<div class=\"info_items\">Viewing 1 of 1 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df.rows.select(df[\"num\"]==1).table()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Select by type\n",
    "### Spark \n",
    "Not available in Spark Vanilla."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       "    .data_type {\n",
       "        font-size: 0.8em;\n",
       "        font-weight: normal;\n",
       "    }\n",
       "\n",
       "    .column_name {\n",
       "        font-size: 1.2em;\n",
       "    }\n",
       "\n",
       "    .info_items {\n",
       "        margin: 10px 0;\n",
       "        font-size: 0.8em;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(even) {\n",
       "        background-color: #f2f2f2 !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(odd) {\n",
       "        background-color: #ffffff !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table thead {\n",
       "        border-bottom: 1px solid black;\n",
       "    }\n",
       "    .optimus_table{\n",
       "        font-size: 12px;\n",
       "    }\n",
       "\n",
       "</style>\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "<div class=\"info_items\">Viewing 1 of 1 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n",
       "\n",
       "<table class=\"optimus_table\">\n",
       "    <thead>\n",
       "    <tr>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">words</div>\n",
       "            <div class=\"data_type\">1 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">num</div>\n",
       "            <div class=\"data_type\">2 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">animals</div>\n",
       "            <div class=\"data_type\">3 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">thing</div>\n",
       "            <div class=\"data_type\">4 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">second</div>\n",
       "            <div class=\"data_type\">5 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">filter</div>\n",
       "            <div class=\"data_type\">6 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "    </tr>\n",
       "\n",
       "    </thead>\n",
       "    <tbody>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            simpsons⸱⸱⸱cat⸱lady\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            2\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            frog\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            table\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            7\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            1\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    </tbody>\n",
       "</table>\n",
       "\n",
       "<div class=\"info_items\">Viewing 1 of 1 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df.rows.select_by_dtypes(\"filter\", \"integer\").table()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Drop \n",
    "### Spark\n",
    "Drop by row not available in Spark Vanilla"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       "    .data_type {\n",
       "        font-size: 0.8em;\n",
       "        font-weight: normal;\n",
       "    }\n",
       "\n",
       "    .column_name {\n",
       "        font-size: 1.2em;\n",
       "    }\n",
       "\n",
       "    .info_items {\n",
       "        margin: 10px 0;\n",
       "        font-size: 0.8em;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(even) {\n",
       "        background-color: #f2f2f2 !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(odd) {\n",
       "        background-color: #ffffff !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table thead {\n",
       "        border-bottom: 1px solid black;\n",
       "    }\n",
       "    .optimus_table{\n",
       "        font-size: 12px;\n",
       "    }\n",
       "\n",
       "</style>\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "<div class=\"info_items\">Viewing 1 of 1 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n",
       "\n",
       "<table class=\"optimus_table\">\n",
       "    <thead>\n",
       "    <tr>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">words</div>\n",
       "            <div class=\"data_type\">1 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">num</div>\n",
       "            <div class=\"data_type\">2 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">animals</div>\n",
       "            <div class=\"data_type\">3 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">thing</div>\n",
       "            <div class=\"data_type\">4 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">second</div>\n",
       "            <div class=\"data_type\">5 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">filter</div>\n",
       "            <div class=\"data_type\">6 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "    </tr>\n",
       "\n",
       "    </thead>\n",
       "    <tbody>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            None\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            3\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            eagle\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            glass\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            8\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            c\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    </tbody>\n",
       "</table>\n",
       "\n",
       "<div class=\"info_items\">Viewing 1 of 1 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df.rows.drop((df[\"num\"]==2) | (df[\"second\"]==5)).table()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       "    .data_type {\n",
       "        font-size: 0.8em;\n",
       "        font-weight: normal;\n",
       "    }\n",
       "\n",
       "    .column_name {\n",
       "        font-size: 1.2em;\n",
       "    }\n",
       "\n",
       "    .info_items {\n",
       "        margin: 10px 0;\n",
       "        font-size: 0.8em;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(even) {\n",
       "        background-color: #f2f2f2 !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(odd) {\n",
       "        background-color: #ffffff !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table thead {\n",
       "        border-bottom: 1px solid black;\n",
       "    }\n",
       "    .optimus_table{\n",
       "        font-size: 12px;\n",
       "    }\n",
       "\n",
       "</style>\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "<div class=\"info_items\">Viewing 3 of 3 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n",
       "\n",
       "<table class=\"optimus_table\">\n",
       "    <thead>\n",
       "    <tr>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">words</div>\n",
       "            <div class=\"data_type\">1 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">num</div>\n",
       "            <div class=\"data_type\">2 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">animals</div>\n",
       "            <div class=\"data_type\">3 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">thing</div>\n",
       "            <div class=\"data_type\">4 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">second</div>\n",
       "            <div class=\"data_type\">5 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">filter</div>\n",
       "            <div class=\"data_type\">6 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "    </tr>\n",
       "\n",
       "    </thead>\n",
       "    <tbody>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱I⸱like⸱⸱⸱⸱⸱fish⸱⸱\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            1\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            dog⸱dog\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            housé\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            5\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            a\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱⸱⸱zombies\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            2\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            cat\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            tv\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            6\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            b\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            None\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            3\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            eagle\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            glass\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            8\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            c\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    </tbody>\n",
       "</table>\n",
       "\n",
       "<div class=\"info_items\">Viewing 3 of 3 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df.rows.drop_by_dtypes(\"filter\", \"int\").table()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Drop by type"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       "    .data_type {\n",
       "        font-size: 0.8em;\n",
       "        font-weight: normal;\n",
       "    }\n",
       "\n",
       "    .column_name {\n",
       "        font-size: 1.2em;\n",
       "    }\n",
       "\n",
       "    .info_items {\n",
       "        margin: 10px 0;\n",
       "        font-size: 0.8em;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(even) {\n",
       "        background-color: #f2f2f2 !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(odd) {\n",
       "        background-color: #ffffff !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table thead {\n",
       "        border-bottom: 1px solid black;\n",
       "    }\n",
       "    .optimus_table{\n",
       "        font-size: 12px;\n",
       "    }\n",
       "\n",
       "</style>\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "<div class=\"info_items\">Viewing 3 of 3 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n",
       "\n",
       "<table class=\"optimus_table\">\n",
       "    <thead>\n",
       "    <tr>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">words</div>\n",
       "            <div class=\"data_type\">1 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">num</div>\n",
       "            <div class=\"data_type\">2 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">animals</div>\n",
       "            <div class=\"data_type\">3 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">thing</div>\n",
       "            <div class=\"data_type\">4 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">second</div>\n",
       "            <div class=\"data_type\">5 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">filter</div>\n",
       "            <div class=\"data_type\">6 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "    </tr>\n",
       "\n",
       "    </thead>\n",
       "    <tbody>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱I⸱like⸱⸱⸱⸱⸱fish⸱⸱\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            1\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            dog⸱dog\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            housé\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            5\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            a\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱⸱⸱zombies\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            2\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            cat\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            tv\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            6\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            b\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            None\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            3\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            eagle\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            glass\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            8\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            c\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    </tbody>\n",
       "</table>\n",
       "\n",
       "<div class=\"info_items\">Viewing 3 of 3 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df.rows.drop_by_dtypes(\"filter\", \"integer\").table()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Drop using an abstract UDF"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       "    .data_type {\n",
       "        font-size: 0.8em;\n",
       "        font-weight: normal;\n",
       "    }\n",
       "\n",
       "    .column_name {\n",
       "        font-size: 1.2em;\n",
       "    }\n",
       "\n",
       "    .info_items {\n",
       "        margin: 10px 0;\n",
       "        font-size: 0.8em;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(even) {\n",
       "        background-color: #f2f2f2 !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table tr:nth-child(odd) {\n",
       "        background-color: #ffffff !important;\n",
       "    }\n",
       "\n",
       "    .optimus_table thead {\n",
       "        border-bottom: 1px solid black;\n",
       "    }\n",
       "    .optimus_table{\n",
       "        font-size: 12px;\n",
       "    }\n",
       "\n",
       "</style>\n",
       "\n",
       "\n",
       "\n",
       "\n",
       "<div class=\"info_items\">Viewing 1 of 1 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n",
       "\n",
       "<table class=\"optimus_table\">\n",
       "    <thead>\n",
       "    <tr>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">words</div>\n",
       "            <div class=\"data_type\">1 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">num</div>\n",
       "            <div class=\"data_type\">2 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">animals</div>\n",
       "            <div class=\"data_type\">3 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">thing</div>\n",
       "            <div class=\"data_type\">4 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">second</div>\n",
       "            <div class=\"data_type\">5 (int)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "        <th>\n",
       "            <div class=\"column_name\">filter</div>\n",
       "            <div class=\"data_type\">6 (string)</div>\n",
       "            <div class=\"data_type\">\n",
       "                \n",
       "                nullable\n",
       "                \n",
       "            </div>\n",
       "        </th>\n",
       "        \n",
       "    </tr>\n",
       "\n",
       "    </thead>\n",
       "    <tbody>\n",
       "    \n",
       "    <tr>\n",
       "        \n",
       "        <td>\n",
       "            ⸱⸱I⸱like⸱⸱⸱⸱⸱fish⸱⸱\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            1\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            dog⸱dog\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            housé\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            5\n",
       "        </td>\n",
       "        \n",
       "        <td>\n",
       "            a\n",
       "        </td>\n",
       "        \n",
       "    </tr>\n",
       "    \n",
       "    </tbody>\n",
       "</table>\n",
       "\n",
       "<div class=\"info_items\">Viewing 1 of 1 rows / 6 columns</div>\n",
       "<div class=\"info_items\">4 partition(s)</div>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from optimus.audf import abstract_udf as audf\n",
    "\n",
    "def func_data_type(value, attr):\n",
    "    return value >1\n",
    "\n",
    "\n",
    "df.rows.drop(audf(\"num\", func_data_type, \"boolean\")).table()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
